<?php
define('ROOT', __DIR__);
define('LOG_DIR', '/logs/qiujiahui.com/');
define('ADMIN_HOST', 'qiujiahui.com');
define('IS_CLI', PHP_SAPI == 'cli');

define('COLOR_DarkGary',  '404040');
define('COLOR_LightGary', 'aaaaaa');
define('COLOR_LightBg',   'f7f7f7');
define('COLOR_MidBg',     'f7f7f7');
define('COLOR_DarkBg',    'dfdfdf');
define('COLOR_White',     'ffffff');
define('COLOR_AlertRed',  'f8525b');
define('COLOR_Red',       '463436');
define('COLOR_BlueBg',    '40a4f7');

//todo: set in php.ini
//ini_set('mbstring.internal_encoding', 'UTF-8');
//require __DIR__ . '/vendor/autoload.php';


spl_autoload_register(function ($name) {
	$lib_folders = ['model', 'lib', 'controller', 'interface', 'controller/admin'];	//如果需要，可以支持更多的目录
	$name = strtr($name, '\\', DIRECTORY_SEPARATOR);
	foreach ($lib_folders as $folder) {
		if (file_exists(ROOT . "/{$folder}/{$name}.php")) {
			require ROOT . "/{$folder}/{$name}.php";
			break;
		}
	}
});

if (strpos(ROOT, '/test/') === 0)
	define('ON_PRODUCTION', 0);
else
	define('ON_PRODUCTION', 1);


set_exception_handler(array('ErrorHandler', 'handleException'));
set_error_handler(array('ErrorHandler', 'handleError'));
register_shutdown_function(array('ErrorHandler', 'handleShutdown'));


include ROOT . "/lib/Core.php";
include ROOT . "/lib/Util.php";
include ROOT . "/lib/Query.php";
